package com.dhcc.stream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;

/**
 * @ClassName: Stream_01
 * @Description: 初玩Stream,单列集合
 * @author weiyongpeng
 * @date 2023年5月7日 下午3:11:47
 */
public class Stream_02 {
	public static <T> void main(String[] args) {
		// 声明单列集合
		ArrayList<String> list = new ArrayList<>();
		
		// 利用Collections的静态方法
		Collections.addAll(list, "a","b","c","d");
		// 获取到一条流水线，同时把数据放到流水线上
		Stream<String> stream1 = list.stream();
		stream1.forEach(new Consumer<String>() {

			@Override
			public void accept(String t) {
				// TODO Auto-generated method stub
				System.out.println(t);
			}
		});
		System.out.println("-------------------------------");
		list.stream().forEach(s->{System.out.println(s);});
	}
}
